//
//  FKIncomDetailListCell.m
//  WanTao
//
//  Created by Macbook Pro on 2019/3/14.
//  Copyright © 2019 Macbook Pro. All rights reserved.
//

#import "FKIncomDetailListCell.h"
#import "FKOrderGoods.h"

@interface FKIncomDetailListCell ()

@property (nonatomic, weak) UIImageView *pictureView;
@property (nonatomic, weak) UILabel *titleLabel;

@end

@implementation FKIncomDetailListCell

- (void)setupSubviews
{
    [super setupSubviews];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    UIImageView *pictureView = [[UIImageView alloc] init];
    [self.contentView addSubview:pictureView];
    self.pictureView = pictureView;
    [pictureView fk_viewCornerRadius:2 borderWidth:0 borderColor:nil];
    
    UILabel *titleLabel = [UILabel fk_labelWithFont:fk_adjustFont(12) textColor:fkColor333333];
    [self.contentView addSubview:titleLabel];
    self.titleLabel = titleLabel;
    titleLabel.numberOfLines = 2;
    
    UIView *separator = [[UIView alloc] init];
    [self.contentView addSubview:separator];
    separator.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    [pictureView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(fk_adjustW(45));
        make.left.offset(12);
        make.centerY.offset(0);
    }];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(pictureView.mas_right).offset(8);
        make.right.offset(-12);
        make.centerY.offset(0);
    }];
    [separator mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(pictureView);
        make.right.equalTo(titleLabel);
        make.bottom.offset(0);
        make.height.offset(0.8);
    }];
}

- (void)setData:(id)data
{
    [super setData:data];
    
    FKOrderGoods *model = data;
    [self.pictureView sd_setImageWithURL:[NSURL URLWithString:model.goods_img] placeholderImage:kPlaceholder_1x1];
    self.titleLabel.text = model.goods_title;
}

@end
